package com.luxury.utils;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * 网络请求工具类
 * Created by ironGe on 2016/12/19.
 */

public class HttpUtils {
    //全局只有一个retrofit
    public static Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(URLContants.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())     //解析成bean类对象
            .addConverterFactory(ScalarsConverterFactory.create())      //解析成字符串
            .build();

    /**
     * 获取系统唯一的retrofit
     *
     * @return retrofit
     */
    public static Retrofit getRetrofitInstance() {
        return retrofit;
    }
    //
    //    //gson解析
    //    public static Object parseJsonToBean(String jsonString) {
    //        Gson gson = new Gson();
    //        return gson.fromJson(jsonString, new TypeToken<Object>() {
    //        }.getType());
    //    }
}
